package com.my.simple.service.auth;

import com.my.simple.entity.auth.Role;
import com.my.simple.entity.auth.RoleOperation;
import com.my.simple.repository.dao.AuthRoleDao;
import com.my.simple.repository.dao.AuthRoleOperationDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private AuthRoleDao authRoleDao;
    @Autowired
    private AuthRoleOperationDao roleOperation;
    @Autowired
    private AuthService authService;

    @Override
    public Role getRoleById(Integer roleId) {
        return authRoleDao.getRoleById(roleId);
    }

    @Override
    public List<Role> getAllRole(){
        return authRoleDao.getAllRole();
    }

    @Override
    public void addRole(Role role) {
        authRoleDao.addRole(role);
    }

    @Override
    public void deleteRoleById(Integer roleId) {
        authRoleDao.deleteRoleById(roleId);
    }

    @Override
    public void updateRole(Role roleItem) {
        authRoleDao.updateRole(roleItem);
    }

    @Override
    public void addRoleOperation(Integer roleId, Integer operationId) {
        roleOperation.addRoleOperation(roleId, operationId);
    }

    @Override
    public void deleteRoleOperation(Integer roleId, Integer operationId) {
        roleOperation.deleteRoleOperation(roleId, operationId);
    }

    @Override
    public List<RoleOperation> getRoleOperationByRoleId(Integer roleId) {
        return roleOperation.getRoleOperationByRoleId(roleId);
    }

    @Override
    public void updateRoleOperation(List<RoleOperation> roleOperationList) {
        authService.updateRoleOperation(roleOperationList);
    }

}
